package top.canyue.word_range.pojo.po;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.canyue.word_range.pojo.vo.UserVo;

import java.util.Date;


/**
 * 用户
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    /**
     * id
     */
    @TableId(value = "id",type = IdType.ASSIGN_UUID)
    private String id;
    /**
     * 用户名
     */
    private String name;
    /**
     * 密文密码
     */
    @JSONField(serialize = false,deserialize = false)
    private String passwordHash;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 头像地址
     */
    private String avatarUrl;
    /**
     * 个性签名
     */
    private String signature;
    /**
     * 注册日期
     */
    @TableField(fill = FieldFill.INSERT)
    private Date registerDate;
    /**
     * 积分
     */
    private int activityIntegral = 0;
    /**
     * 删除
     */
    private int deleted = 0;

    public UserVo toVo(){
        UserVo userVo = new UserVo();
        userVo.setId(id);
        userVo.setName(name);
        userVo.setPhone(phone);
        userVo.setAvatarUrl(avatarUrl);
        userVo.setSignature(signature);
        userVo.setActivityIntegral(activityIntegral);
        userVo.setRegisterDate(registerDate);
        return userVo;
    }
}
